package main

import (
	"os"
	"proxy_resource_test/config"
	"proxy_resource_test/internal/boot"
	"proxy_resource_test/internal/command"
	"proxy_resource_test/routes"
	"proxy_resource_test/utils/logging"
)

func main() {
	// 1. 配置和日志
	config.Init()
	logging.Setup()

	app := boot.New(
		boot.WithHTTPRouter(routes.Init()),
		//boot.WithRPCServices([]boot.RPCService{
		//	{Name: "PullResource", Service: new(rpcx_get.PullResource)},
		//}),
	)

	// 如果有命令行参数，则执行服务安装/启动/停止等命令
	if len(os.Args) > 1 {
		if err := command.Handle(app, os.Args[1:]); err != nil {
			logging.Error("命令执行失败: ", err)
		}
		return
	}

	// 否则直接运行服务
	if err := app.Run(); err != nil {
		logging.Error("服务启动失败: ", err)
		os.Exit(1)
	}
}
